package handler

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"yk/api/request"
	"yk/consts"
	"yk/internal/dao"
	"yk/internal/model"
	"yk/internal/queue"
)

func AdminMessage(c *gin.Context) {

	var req request.AdminMessageReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 1000,
			"msg":  "验证失败",
			"data": nil,
		})
		return
	}
	go queue.PublishPub(consts.ADMIN_PUBLISH, req.Message)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "发送成功",
		"data": true,
	})
	var video []model.Video
	get := dao.GetListAuthor()
	for _, i := range get {
		video = append(video, model.Video{

			ExamineName: i.ExamineName,
			ExamineNum:  i.ExamineNum,
			ExamineType: i.ExamineType,
		})
	}
	//dao.GetListByFields(&model.Video{}, &video)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "审核人员展示成功",
		"data": video,
	})

}
